﻿#include "ChessGame.h"

ChessGame::ChessGame(Man *man, AI *ai, Chess *chess)
{
	this->man = man;
	this->ai = ai;
	this->chess = chess;
	man->init(chess);
}

// 开始游戏
void ChessGame::play()
{
	// 棋盘初始化
	chess->init();

	while (1)
	{
		// 玩家先落子
		man->go();

		// 判定是否结束
		if (chess->checkOver())
		{
			chess->init();
			continue;
		}

		// AI落子
		ai->go();

		// 判定是否结束
		if (chess->checkOver())
		{
			chess->init();
			continue;
		}
	}
}
